<template>
  <div id="app">
    <router-view />
  </div>
</template>
<script>
import { setTomtawFavicon } from 'tomtaw-favicon';
import Mgr from '@/utils/SecurityService'
import { mapGetters } from 'vuex';
import store from './store/index'


export default {
  name: 'app',
  data() {
    return {
      // currentSystemPath: {
      //   '/paservice/': ['/paservice/'],
      //   '/paservice/IMGLIST': ['/paservice/IMGLIST', '/paservice/IMGLIST/matching', '/paservice/IMGLIST/splitting'],
      //   '/paservice/IMGPROOFREAD': ['/paservice/IMGPROOFREAD'],
      //   '/paservice/paramsSetting/bacisParams': ['/paservice/paramsSetting/bacisParams', '/paservice/paramsSetting/frontEndProcessorConfig', '/paservice/paramsSetting/imgDeviceConfig', '/paservice/paramsSetting/memoryDeviceConfig', '/paservice/paramsSetting/routingStrategyConfig', '/paservice/paramsSetting/logViewer']
      // }
    }
  },
  computed:{
    ...mapGetters(['loginInfo']),
  },
  // watch: {
  //   $route(to, from) {
  //     let currentPage = ''
  //     Object.keys(this.currentSystemPath).forEach((ele, index) => {
  //       if(this.currentSystemPath[ele].includes(to.path)) {
  //         currentPage = ele
  //       }
  //     })
  //     window.parent.postMessage({currentPage}, '*')
  //   }
  // },
  created() {

    // debugger
    if (!this.loginInfo) {

      const manager = new Mgr()
      // debugger
      manager.getRole().then((userInfo) => {
        // debugger
        if (process.env.NODE_ENV === 'development') {
          //登录15600000000 账号
          //stringify
          console.log(
            "🚀 ~ file: App.vue:48 ~ manager.getRole ~ userInfo:",
            userInfo,JSON.stringify(userInfo));
          }
        let info = JSON.stringify(userInfo)
        store.commit('user/SET_LOGININFO', info)
        setTomtawFavicon(userInfo);
      }).catch(e=>{
        // debugger
        console.log('登录失败');
      });
    } else {
      let user = JSON.parse(this.loginInfo);
      setTomtawFavicon(user);
    } 
  }
}
</script>

<style lang="less">


</style>
